<?php

namespace App\Api\Dao;

use App\Models\TongDistrict;

class DistrictDao extends BaseDao
{

    /**
     * 查询构造器
     * @param $data
     * @return \Illuminate\Database\Eloquent\Builder
     */
    function getBuildQuery($data)
    {

        // TODO: Implement getBuildQuery() method.
        $query = TongDistrict::query();
        if(checkIsHasField($data,'id')){
            $query->where('id',$data['id']);
        }
        if(checkIsHasField($data,'pid')){
            $query->where('pid',$data['pid']);
        }
        return $query;

    }

    /**
     * 获取地区
     * @param array $params
     * @return \Illuminate\Database\Eloquent\Builder[]|\Illuminate\Database\Eloquent\Collection|void
     */
    public function getDistrict(array $params)
    {
        $query = $this->getBuildQuery($params);
        return $query->get();
    }
}
